package structures;

/**
 * Represents the array of characters of the map.
 * 	To be used to populate GUI.  Instantiated in the MapPacket constructor.
 * Use getInstance().
 * 
 * @author lilywong
 */
public class Map {
	/* variables */
	private static Map m;
	int mapRows;
	int mapCols;
	char[] map;
	
	/* Accessors */
	public int getRows() { return mapRows; }
	public int getCols() { return mapCols; }
	public char[] getMap() { return map; }
	
	/* constructor (only ever used in MapPacket */
	public Map( int rows, int cols, char[] mapArray ) {
		this.mapRows = rows;
		this.mapCols = cols;
		this.map = mapArray;
		m = this;
	}
	
	/*
	 * Only 1 instance allowed
	 */
	public static Map getInstance() {
		if ( m == null ) {
			throw new IllegalStateException("Map should have been initialized in MapPacket.");
		}
		return m;
	}
}
